const Joi = require('joi')

const username = Joi.string().alphanum().min(3).max(32).required()
const nickname = Joi.string().min(3).max(32)
const email = Joi.string().email({ minDomainSegments: 2, tlds: { allow: ['com', 'net'] } })
const id = Joi.required()
const password = Joi.string().pattern(/^[\S]{6,15}$/).required()
//  校验 rePassword 值与 password 相同并且必填
const rePassword = Joi.any().valid(Joi.ref('password')).required().label('rePassword')

const user_pic = Joi.string().uri({
    scheme: [
        /^http/,
        /^https/
    ]
})

exports.userInfo_schema = {
    body: {
        username,
        nickname,
        email,
        user_pic,
        id
    }
}
exports.modifyPassword_schema = {
    body: {
        id,
        password,
        rePassword
    }
}
exports.updateAvater_schema = {
    body: {
        id,
        user_pic,
    }
}